<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>pthread_setcancelstate</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_1726">&nbsp;</a>NAME</h4><blockquote>
pthread_setcancelstate, pthread_setcanceltype, pthread_testcancel
- set cancelability state
</blockquote><h4><a name = "tag_000_007_1727">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="pthread.h.html">pthread.h</a>&gt;

int pthread_setcancelstate(int <i>state</i>, int *<i>oldstate</i>);
int pthread_setcanceltype(int <i>type</i>, int *<i>oldtype</i>);
void pthread_testcancel(void);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_1728">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>pthread_setcancelstate()</i>
function atomically both sets the calling thread's cancelability
state to the indicated
<i>state</i>
and returns the previous cancelability state
at the location referenced by <i>oldstate</i>.
Legal values for
<i>state</i>
are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DISABLE.
<p>
The
<i>pthread_setcanceltype()</i>
function atomically both sets the calling thread's cancelability
type to the indicated
<i>type</i>
and returns the previous cancelability type
at the location referenced by <i>oldtype</i>.
Legal values for
<i>type</i>
are PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS.
<p>
The cancelability state and type of any newly
created threads, including the thread in which
<i>main()</i>
was first invoked,
are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DEFERRED
respectively.
<p>
The
<i>pthread_testcancel()</i>
function creates a cancellation point in the calling thread.
The
<i>pthread_testcancel()</i>
function has no effect if cancelability is disabled.
</blockquote><h4><a name = "tag_000_007_1729">&nbsp;</a>RETURN VALUE</h4><blockquote>
If successful, the
<i>pthread_setcancelstate()</i>
and
<i>pthread_setcanceltype()</i>
functions return zero.
Otherwise, an error number is returned to indicate the error.
</blockquote><h4><a name = "tag_000_007_1730">&nbsp;</a>ERRORS</h4><blockquote>
The 
<i>pthread_setcancelstate()</i>
function may fail if:
<dl compact>

<dt>[EINVAL]<dd>
The specified state is not
PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.

</dl>
<p>
The
<i>pthread_setcanceltype()</i>
function may fail if:
<dl compact>

<dt>[EINVAL]<dd>The specified type is not PTHREAD_CANCEL_DEFERRED
or PTHREAD_CANCEL_ASYNCHRONOUS.

</dl>
<p>
These functions will not return an error code of [EINTR].
</blockquote><h4><a name = "tag_000_007_1731">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1732">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1733">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1734">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="pthread_cancel.html">pthread_cancel()</a></i>,
<i><a href="pthread.h.html">&lt;pthread.h&gt;</a></i>.
<br>
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the POSIX Threads Extension (1003.1c-1995)
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

